import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PopulationBaseVO, PopulationBaseForm, PopulationBaseQuery } from '@/api/basicPublic/populationBase/types';

/**
 * 查询人口基数列表
 * @param query
 * @returns {*}
 */

export const listPopulationBase = (query?: PopulationBaseQuery): AxiosPromise<PopulationBaseVO[]> => {
  return request({
    url: '/basicPublic/populationBase/list/'+query.year,
    method: 'get',
    params: query
  });
};

/**
 * 查询人口基数详细
 * @param id
 */
export const getPopulationBase = (id: string | number): AxiosPromise<PopulationBaseVO> => {
  return request({
    url: '/basicPublic/populationBase/' + id,
    method: 'get'
  });
};

/**
 * 新增人口基数
 * @param data
 */
export const addPopulationBase = (data: PopulationBaseForm) => {
  return request({
    url: '/basicPublic/populationBase',
    method: 'post',
    data: data
  });
};

/**
 * 修改人口基数
 * @param data
 */
export const updatePopulationBase = (data: PopulationBaseForm) => {
  return request({
    url: '/basicPublic/populationBase',
    method: 'put',
    data: data
  });
};

/**
 * 删除人口基数
 * @param id
 */
export const delPopulationBase = (id: string | number | Array<string | number>) => {
  return request({
    url: '/basicPublic/populationBase/' + id,
    method: 'delete'
  });
};
